﻿using Microsoft.Practices.Prism.ViewModel;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Media;

namespace FPSO.Models.ViewModel
{
    public class StatusMonitorViewModel : NotificationObject
    {
        public StatusMonitorViewModel()
        {
            windSpeed = 0;
            windDirection = 0;

            TableData = new ObservableCollection<DataItem>();
        }

		private double dispValue;
		public double DispValue
		{
			get { return dispValue; }
			set
			{
				dispValue = value;
				RaisePropertyChanged("DispValue");
			}
		}

		private double deadWeightValue;
		public double DeadWeightValue
		{
			get { return deadWeightValue; }
			set
			{
				deadWeightValue = value;
				RaisePropertyChanged("DeadWeightValue");
			}
		}

		private double lightShipValue;
		public double LightShipValue
		{
			get { return lightShipValue; }
			set
			{
				lightShipValue = value;
				RaisePropertyChanged("LightShipValue");
			}
		}

		private double freeWeightValue;
		public double FreeWeightValue
		{
			get { return freeWeightValue; }
			set
			{
				freeWeightValue = value;
				RaisePropertyChanged("FreeWeightValue");
			}
		}

		private double cargoWeightValue;
		public double CargoWeightValue
		{
			get { return cargoWeightValue; }
			set
			{
				cargoWeightValue = value;
				RaisePropertyChanged("CargoWeightValue");
			}
		}

		private double ballastWeightValue;
		public double BallastWeightValue
		{
			get { return ballastWeightValue; }
			set
			{
				ballastWeightValue = value;
				RaisePropertyChanged("BallastWeightValue");
			}
		}

		private double kmtValue;
		public double KMTValue
		{
			get { return kmtValue; }
			set
			{
				kmtValue = value;
				RaisePropertyChanged("KMTValue");
			}
		}

		private double vcgValue;
		public double VcgValue
		{
			get { return vcgValue; }
			set
			{
				vcgValue = value;
				RaisePropertyChanged("VcgValue");
			}
		}

		private double lcgValue;
		public double LcgValue
		{
			get { return lcgValue; }
			set
			{
				lcgValue = value;
				RaisePropertyChanged("LcgValue");
			}
		}

		private double gmValue;
		public double GMValue
		{
			get { return gmValue; }
			set
			{
				gmValue = value;
				RaisePropertyChanged("GMValue");
			}
		}

		private double sfValue;
		public double SFValue
		{
			get { return sfValue; }
			set
			{
				sfValue = value;
				RaisePropertyChanged("SFValue");
			}
		}

		private double bmValue;
		public double BMValue
		{
			get { return bmValue; }
			set
			{
				bmValue = value;
				RaisePropertyChanged("BMValue");
			}
		}

		private double sfMaxValue;
		public double SFMaxValue
		{
			get { return sfMaxValue; }
			set
			{
				sfMaxValue = value;
				RaisePropertyChanged("SFMaxValue");
			}
		}

		private double bmMaxValue;
		public double BMMaxValue
		{
			get { return bmMaxValue; }
			set
			{
				bmMaxValue = value;
				RaisePropertyChanged("BMMaxValue");
			}
		}

		private double draftLeft;
        private double draftRight;
        private double draftFront;
        private double draftBack;

        /// <summary>
        /// 吃水 左边 
        /// </summary>
        public double DraftLeft
        {
            get { return draftLeft; }
            set
            {
                draftLeft = value;
                RaisePropertyChanged("DraftLeft");
            }
        }

        /// <summary>
        /// 吃水 右边
        /// </summary>
        public double DraftRight
        {
            get { return draftRight; }
            set
            {
                draftRight = value;
                RaisePropertyChanged("DraftRight");
            }
        }

        /// <summary>
        /// 吃水 前面
        /// </summary>
        public double DraftFront
        {
            get { return draftFront; }
            set
            {
                draftFront = value;
                RaisePropertyChanged("DraftFront");
            }
        }

        /// <summary>
        /// 吃水 后面
        /// </summary>
        public double DraftBack
        {
            get { return draftBack; }
            set
            {
                draftBack = value;
                RaisePropertyChanged("DraftBack");
            }
        }

        /// <summary>
        /// 气象海况 - 风速
        /// </summary>
        private double windSpeed;
        public double WindSpeed
        {
            get { return windSpeed; }
            set
            {
                windSpeed = value;
                RaisePropertyChanged("WindSpeed");
            }
        }

        /// <summary>
        /// 气象海况 - 风向
        /// </summary>
        private double windDirection;
        public double WindDirection
        {
            get { return windDirection; }
            set
            {
                windDirection = value;
                RaisePropertyChanged("WindDirection");
            }
        }

        private double longitude;
        /// <summary>
        /// 经度
        /// </summary>
        public double Longitude
        {
            get { return longitude; }
            set
            {
                longitude = value;
                RaisePropertyChanged("Longitude");
            }
        }

        private double latitude;
        /// <summary>
        /// 纬度
        /// </summary>
        public double Latitude
        {
            get { return latitude; }
            set
            {
                latitude = value;
                RaisePropertyChanged("Latitude");
            }
        }

        private double leftRudderAngle;
        /// <summary>
        /// 左舵角
        /// </summary>
        public double LeftRudderAngle
        {
            get { return leftRudderAngle; }
            set
            {
                leftRudderAngle = value;
                RaisePropertyChanged("LeftRudderAngle");
            }
        }

        private double rightRudderAngle;
        /// <summary>
        /// 右舵角
        /// </summary>
        public double RightRudderAngle
        {
            get { return rightRudderAngle; }
            set
            {
                rightRudderAngle = value;
                RaisePropertyChanged("RightRudderAngle");
            }
        }

        private double trimAngle;
        /// <summary>
        /// 纵倾
        /// </summary>
        public double TrimAngle
        {
            get { return trimAngle; }
            set
            {
                trimAngle = value;
                RaisePropertyChanged("TrimAngle");
            }
        }

        private double heelAngle;
        /// <summary>
        /// 横倾
        /// </summary>
        public double HeelAngle
        {
            get { return heelAngle; }
            set
            {
                heelAngle = value;
                RaisePropertyChanged("HeelAngle");
            }
        }

        private double h1p;
        private double h2p;
        private double h3p;
        private double h4p;
        private double h5p;
        private double h1s;
        private double h2s;
        private double h3s;
        private double h4s;
        private double h5s;
        private double y1p;
        private double y2p;
        private double y3p;
        private double y4p;
        private double y5p;
        private double y1s;
        private double y2s;
        private double y3s;
        private double y4s;
        private double y5s;
        public double H1P
        {
            get { return h1p; }
            set
            {
                h1p = value;
                RaisePropertyChanged("H1P");
            }
        }
        public double H2P
        {
            get { return h2p; }
            set
            {
                h2p = value;
                RaisePropertyChanged("H2P");
            }
        }
        public double H3P
        {
            get { return h3p; }
            set
            {
                h3p = value;
                RaisePropertyChanged("H3P");
            }
        }
        public double H4P
        {
            get { return h4p; }
            set
            {
                h4p = value;
                RaisePropertyChanged("H4P");
            }
        }
        public double H5P
        {
            get { return h5p; }
            set
            {
                h5p = value;
                RaisePropertyChanged("H5P");
            }
        }
        public double H1S
        {
            get { return h1s; }
            set
            {
                h1s = value;
                RaisePropertyChanged("H1S");
            }
        }
        public double H2S
        {
            get { return h2s; }
            set
            {
                h2s = value;
                RaisePropertyChanged("H2S");
            }
        }
        public double H3S
        {
            get { return h3s; }
            set
            {
                h3s = value;
                RaisePropertyChanged("H3S");
            }
        }
        public double H4S
        {
            get { return h4s; }
            set
            {
                h4s = value;
                RaisePropertyChanged("H4S");
            }
        }
        public double H5S
        {
            get { return h5s; }
            set
            {
                h5s = value;
                RaisePropertyChanged("H5S");
            }
        }
        public double Y1P
        {
            get { return y1p; }
            set
            {
                y1p = value;
                RaisePropertyChanged("Y1P");
            }
        }
        public double Y2P
        {
            get { return y2p; }
            set
            {
                y2p = value;
                RaisePropertyChanged("Y2P");
            }
        }
        public double Y3P
        {
            get { return y3p; }
            set
            {
                y3p = value;
                RaisePropertyChanged("Y3P");
            }
        }
        public double Y4P
        {
            get { return y4p; }
            set
            {
                y4p = value;
                RaisePropertyChanged("Y4P");
            }
        }
        public double Y5P
        {
            get { return y5p; }
            set
            {
                y5p = value;
                RaisePropertyChanged("Y5P");
            }
        }
        public double Y1S
        {
            get { return y1s; }
            set
            {
                y1s = value;
                RaisePropertyChanged("Y1S");
            }
        }
        public double Y2S
        {
            get { return y2s; }
            set
            {
                y2s = value;
                RaisePropertyChanged("Y2S");
            }
        }
        public double Y3S
        {
            get { return y3s; }
            set
            {
                y3s = value;
                RaisePropertyChanged("Y3S");
            }
        }
        public double Y4S
        {
            get { return y4s; }
            set
            {
                y4s = value;
                RaisePropertyChanged("Y4S");
            }
        }
        public double Y5S
        {
            get { return y5s; }
            set
            {
                y5s = value;
                RaisePropertyChanged("Y5S");
            }
        }

        /// <summary>
        /// 数据表格
        /// </summary>
        public ObservableCollection<DataItem> TableData { get; set; }
        public void AddRow()
        {
            TableData.Add(new DataItem());
        }

        public void DeleteSelectedRow(int selectedIndex)
        {
            if (selectedIndex >= 0 && selectedIndex < TableData.Count)
            {
                TableData.RemoveAt(selectedIndex);
            }
        }
       
    }

    public class DataItem
    {
        public string Name { get; set; }
        public string Comm { get; set; }
        public double EmptyHeight { get; set; }
        public double Volume { get; set; }
        public double Density { get; set; }
        public double Weight { get; set; }
        public double Percentage { get; set; }
        public double Temperature { get; set; }
        public double Pressure { get; set; }
        public double LiquidLevel { get; set; }
        public double CenterOfGravityX { get; set; }
        public double CenterOfGravityY { get; set; }
        public double CenterOfGravityZ { get; set; }
        public double LateralMomentOfInertia { get; set; }
        public string LateralInertiaType { get; set; }

        public string GetColumnValue(int colIndex)
        {
            switch (colIndex)
            {
                case 0: return Name;
                case 1: return Comm;
                case 2: return EmptyHeight.ToString();
                case 3: return Volume.ToString();
                case 4: return Density.ToString();
                case 5: return Weight.ToString();
                case 6: return Percentage.ToString();
                case 7: return Temperature.ToString();
                case 8: return Pressure.ToString();
                case 9: return LiquidLevel.ToString();
                case 10: return CenterOfGravityX.ToString();
                case 11: return CenterOfGravityY.ToString();
                case 12: return CenterOfGravityZ.ToString();
                case 13: return LateralMomentOfInertia.ToString();
                case 14: return LateralInertiaType;
                default: return "";
            }
        }
    }


}
